package com.example.lucky.draw.server.service.impl;

import com.example.lucky.draw.server.common.enums.DrawEnum;
import com.example.lucky.draw.server.common.handler.DrawException;
import com.example.lucky.draw.server.protocol.po.ActivityPrize;
import com.example.lucky.draw.server.repository.ActivityPrizeRepository;
import com.example.lucky.draw.server.service.IActivityPrizeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityPrizeServiceImpl implements IActivityPrizeService {

    @Autowired
    private ActivityPrizeRepository activityPrizeRepository;

    @Override
    public void saveAll(List<ActivityPrize> activityPrizes) {
        List<ActivityPrize> activityPrizeList = activityPrizeRepository.saveAll(activityPrizes);
        if (activityPrizeList.isEmpty()){
            throw new DrawException(DrawEnum.INSERT_ERROR);
        }
    }
}
